package com.lcb.manager.repository;

import com.lcb.manager.entity.News;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

public interface NewsRepository extends JpaRepository<News, Integer> {

    @Query(value = "select * from news where year(`date`) = ?1 and month(`date`) = ?2 ",
            countQuery = "select count(*) from news where year(`date`) = ?1 and month(`date`) = ?2 ",
            nativeQuery = true)
    Page<News> findByDateOrderByDateAsc(String year, String month, Pageable pageable);

    Page<News> findByOrderByDateAsc(Pageable pageable);

}
